package com.leo.entity;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.dsl.components.KeepOnScreenComponent;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import com.leo.component.SpriteComponent;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-06  22:03
 * @Description: TODO
 */
public class SpriteEntityFactory implements EntityFactory {

    @Spawns("sprite")
    public Entity createSprite(SpawnData spawnData) {
        return FXGL.entityBuilder(spawnData)
                // 让玩家一直保持在窗口之中
                .with(new KeepOnScreenComponent())
                .with(new SpriteComponent())
                .bbox(new HitBox(BoundingShape.box((double) 160 / 4, (double) 216 / 4)))
                .build();
    }
}
